<?php
/**
 * Created by PhpStorm.
 * User: xiaoyang
 * Date: 2019/1/11
 * Time: 19:09
 */

namespace app\general\controller;


use app\general\model\SqApk;
use app\v2\model\AppApk;
use think\Controller;

class Apk extends Controller
{
    //apk审核状态
    public function checkApk()
    {
        $version = input('version');
		// $type = input('type');
        // if ($type == 'android'){
			// $info=(new AppApk())->order("id desc")->limit(1)->find();
			// return success($info);
        // }
        if(!$version) error('版本号必传：version');

        $info = (new SqApk())->where('version', $version)->find();
        if(!$info) error('无此版本');
        return success($info);
    }

    // APP下载地址
    public function AppDownload()
    {
        if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
            header("Location: http://baidu.com");
        }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){
            header("Location: https://www.pgyer.com/xytn");
        }else{
            echo 'systerm is other';
        }
    }
    /**
     * 获取android版本号信息
     */
    public function checkAppApk(){
        $info=(new AppApk())->order("id desc")->limit(1)->find();
        return success($info);
    }
}

